/**
 * 快递下单处理
 */
import md5 from 'js-md5'
import * as cache from '../../util/cache'

const paramsKey = 'ex-' + md5('express')

export default {
  namespaced: true,
  state: {
    params: {},
    // 优惠券
    // ticket: '',
  },
  getters: {
    // params: state => state.params,
    params: state => {
      if (Object.keys(state.params).length === 0) {
        state.params = cache.get(paramsKey)
      }
      return state.params
    },
    // ticket: state => state.title
  },
  mutations: {
    SET_PARAMS: (state, params) => {
      state.params = params
      cache.save(paramsKey, params)
    },
    // SET_TICKET: (state, amount) => {
    //   state.ticket = amount
    // }
  },
  actions: {
    set_params: ({ commit }, params) => {
      commit('SET_PARAMS', params)
    },
    // set_ticket: ({ commit }, amount) => {
    //   commit('SET_TICKET', amount)
    // }
  }
}
